﻿<%@ Page Language="VB" AutoEventWireup="false" CodeFile="messaggi_lookup_form.aspx.vb"
    Inherits="m_gestione_messaggi_lookup_form" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Dettagli Messaggio</title>
    <link href="/timereport/include/commoncss.aspx" rel="stylesheet" type="text/css" />
    </head>
<script language="JavaScript" src="/timereport/include/menu/menu_array.js" type="text/javascript"></script>
<script language="JavaScript" src="/timereport/include/menu/mmenu.js" type="text/javascript"></script>
<body>
    <table width="760" border="0">
        <tr>
            <td height="30" class="BarraTop" align="right">
                Utente:
                <%= session("UserName") %>
            </td>
        </tr>
    </table>
    <form id="form1" runat="server">
    <div>
        <asp:FormView ID="SchedaMessaggio" runat="server" DataKeyNames="MessaggioID" DataSourceID="SqlDataSource1"
            EnableModelValidation="True" CssClass="DetailsView" DefaultMode="Insert">
            <EditItemTemplate>
                <table  BorderStyle="Solid" BorderWidth="1px">
                    <tr>
                        <th colspan="2">
                            Scheda messaggio
                        </th>
                    </tr>
                    <tr>
                        <td>
                            Titolo
                        </td>
                        <td>
                            <asp:TextBox ID="TitoloTextBox" runat="server" Columns="20" MaxLength="20" OnTextChanged="TitoloTextBox_TextChanged"
                                Text='<%# Bind("Titolo") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Valido da
                        </td>
                        <td>
                            <asp:TextBox ID="DataDaTextBox" runat="server" Columns="10" MaxLength="10" Text='<%# Bind("DataDa", "{0:d}") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Valido fino
                        </td>
                        <td>
                            <asp:TextBox ID="DataATextBox" runat="server" Columns="10" MaxLength="10" Text='<%# Bind("DataA", "{0:d}") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Testo messaggio
                        </td>
                        <td>
                            <asp:TextBox ID="MessaggioTextBox" runat="server" Columns="25" MaxLength="100" Rows="4"
                                Text='<%# Bind("Messaggio") %>' TextMode="MultiLine" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
                <br />
                <br />
                <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    CssClass="FormButton" Text="Aggiorna" />
                &nbsp;<asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False"
                    CommandName="Cancel" CssClass="FormButton" Text="Annulla" />
            </EditItemTemplate>
            <InsertItemTemplate>
                <table  BorderStyle="Solid" BorderWidth="1px">
                    <tr>
                        <th colspan="2">
                            Scheda messaggio
                        </th>
                    </tr>
                    <tr>
                        <td>
                            Titolo
                        </td>
                        <td>
                            <asp:TextBox ID="TitoloTextBox" runat="server" Columns="20" MaxLength="20" OnTextChanged="TitoloTextBox_TextChanged"
                                Text='<%# Bind("Titolo") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Valido da
                        </td>
                        <td>
                            <asp:TextBox ID="DataDaTextBox" runat="server" Columns="10" MaxLength="10" Text='<%# Bind("DataDa", "{0:d}") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Valido fino
                        </td>
                        <td>
                            <asp:TextBox ID="DataATextBox" runat="server" Columns="10" MaxLength="10" Text='<%# Bind("DataA", "{0:d}") %>' />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Testo messaggio
                        </td>
                        <td>
                            <asp:TextBox ID="MessaggioTextBox" runat="server" Columns="25" MaxLength="100" Rows="4"
                                Text='<%# Bind("Messaggio") %>' TextMode="MultiLine" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
                <br />
                <br />
                <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                    Text="Inserisci" CssClass="FormButton" />
                &nbsp;<asp:Button ID="InsertCancelButton" runat="server" CausesValidation="False"
                    CommandName="Cancel" Text="Annulla" CssClass="FormButton" />
            </InsertItemTemplate>
            <ItemTemplate>
                DataDa:
                <asp:Label ID="DataDaLabel" runat="server" Text='<%# Bind("DataDa", "{0:d}") %>' />
                <br />
                DataA:
                <asp:Label ID="DataALabel" runat="server" Text='<%# Bind("DataA", "{0:d}") %>' />
                <br />
                Titolo:
                <asp:Label ID="TitoloLabel" runat="server" Text='<%# Bind("Titolo") %>' />
                <br />
                Messaggio:
                <asp:Label ID="MessaggioLabel" runat="server" Text='<%# Bind("Messaggio") %>' />
                <br />
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MSSql12155ConnectionString %>"
            SelectCommand="SELECT * FROM [Messaggi] WHERE ([MessaggioID] = @MessaggioID)"
            DeleteCommand="DELETE FROM [Messaggi] WHERE [MessaggioID] = @original_MessaggioID"
            InsertCommand="INSERT INTO [Messaggi] ([DataDa], [DataA], [Titolo], [Messaggio]) VALUES (@DataDa, @DataA, @Titolo, @Messaggio)"
            OldValuesParameterFormatString="original_{0}" 
            UpdateCommand="UPDATE [Messaggi] SET [DataDa] = @DataDa, [DataA] = @DataA, [Titolo] = @Titolo, [Messaggio] = @Messaggio WHERE [MessaggioID] = @original_MessaggioID">
            <DeleteParameters>
                <asp:Parameter Name="original_MessaggioID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="DataDa" Type="DateTime" />
                <asp:Parameter Name="DataA" Type="DateTime" />
                <asp:Parameter Name="Titolo" Type="String" />
                <asp:Parameter Name="Messaggio" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:QueryStringParameter Name="MessaggioID" QueryStringField="MessaggioID" Type="Int32" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter Name="DataDa" Type="DateTime" />
                <asp:Parameter Name="DataA" Type="DateTime" />
                <asp:Parameter Name="Titolo" Type="String" />
                <asp:Parameter Name="Messaggio" Type="String" />
                <asp:Parameter Name="original_MessaggioID" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>
